// utils/Components/time-label/time-label.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    formatter:{
      type:"string",
      value:"yyyy年MM月dd日 hh:mm:ss"
    },
    value: {
      type: "string",
      value: "",
      observer: function (newVal, oldVal) {
        let that = this;
        let type = Object.prototype.toString.call(newVal);
        if(type == '[object String]'){
          this.setData({
            timeString:wx.su.formatTime(wx.su.tdtt(newVal),this.data.formatter)
          })
        }
        else if(type == '[object Number]')
        {
          this.setData({
            timeString:wx.su.formatTime(newVal,this.data.formatter)
          })
        }
        else if(type == '[object Date]')
        {
          this.setData({
            timeString:wx.su.formatTime(newVal.getTime(),this.data.formatter)
          })
        }
        else{
          this.setData({
            timeString:""
          })
        }
      }
    }

  },

  /**
   * 组件的初始数据
   */
  data: {
    timeString:''
  },

  /**
   * 组件的方法列表
   */
  methods: {

  }
})
